//
//  LearnHomeCell.m
//  GuShiNews
//
//  Created by 丁一 on 2019/8/22.
//  Copyright © 2019 Jones. All rights reserved.
//

#import "LearnHomeCell.h"
#import "LearnModel.h"

@interface LearnHomeCell ()

@property (nonatomic, strong) UILabel *Label_tittle;
@property (nonatomic, strong) UILabel *Label_bottom;
@property (nonatomic, strong) UIImageView *News_image;

@property (nonatomic, strong) CALayer *News_line;

@end

@implementation LearnHomeCell

+ (instancetype)cellForTableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"LearnHomeCell";
    
    LearnHomeCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell)
    {
        cell = [[LearnHomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        cell.backgroundColor          = [UIColor whiteColor];
        
        [cell.contentView addSubview:cell.Label_tittle];
        [cell.contentView addSubview:cell.Label_bottom];
        [cell.contentView addSubview:cell.News_image];
        [cell.contentView.layer addSublayer:cell.News_line];
        
    }
    
    return cell;
}

- (void)setModel:(LearnModel *)Model{
    if (_Model != Model) {
        _Model = Model;
    }
    
    _Label_tittle.text=_Model.learn_tittle;
    [_News_image sd_setImageWithURL:[NSURL URLWithString:_Model.learn_logo] placeholderImage:[UIImage imageNamed:@"morentu.png"]];
}

-(UILabel *)Label_tittle{
    if (!_Label_tittle) {
        _Label_tittle           = [[UILabel alloc] init];
        _Label_tittle.font      = [UIFont boldSystemFontOfSize:17];
        _Label_tittle.textColor = NewsTitleColor;
        _Label_tittle.numberOfLines = 2;
        _Label_tittle.frame=CGRectMake(20, 20, RECRWITCH/3*2-40, 50);
        //        _Label_tittle.lineBreakMode = NSLineBreakByCharWrapping;
    }
    return _Label_tittle;
}

-(UILabel *)Label_bottom{
    if (!_Label_bottom) {
        _Label_bottom           = [[UILabel alloc] init];
        _Label_bottom.font      = [UIFont systemFontOfSize:13];
        _Label_bottom.textColor = NewsotherColor;
        _Label_bottom.frame = CGRectMake(20, 75, _Label_tittle.frame.size.width, 20);
    }
    return _Label_bottom;
}

-(UIImageView *)News_image{
    if (!_News_image) {
        _News_image                     = [[UIImageView alloc] init];
        _News_image.layer.masksToBounds = YES;
        _News_image.layer.cornerRadius  = 5;
        _News_image.contentMode         = UIViewContentModeScaleAspectFill;
        _News_image.backgroundColor = backColor;
        _News_image.frame=CGRectMake(RECRWITCH/3*2, 20, RECRWITCH/3-20, 80);
    }
    return _News_image;
}

- (CALayer *)News_line{
    if (!_News_line) {
        _News_line = [[CALayer alloc] init];
        _News_line.frame=CGRectMake(20, 119, RECRWITCH-40, 0.7);
        _News_line.backgroundColor=LineColor.CGColor;
    }
    return _News_line;
}

@end
